package day05;

import java.util.Random;

public class MethodDemo2 {
    public static void main(String[] args) {
        /*
        int a = sum(5,6);
        System.out.println(a);
        int m=5,n=6;
        int b = sum(m,n);
        System.out.println(b);

         */
        int[] c = generateArray(10,100);
        System.out.println("数组的长度为："+c.length);
        for (int i = 0;i < c.length;i++){
            System.out.println(c[i]);
        }

        int[] d = generateArray(10,100);
        System.out.println("数组中第一个元素的值为："+d[0]);
        for (int i = 0;i < d.length;i++){
            System.out.println(d[i]);
        }
    }
    public static int[] generateArray(int len,int max){
        int[] arr = new int[len];
        Random rand = new Random();
        for (int i = 0;i < arr.length;i++){
            //arr[i] = (int)(Math.random()*(max+1));
            arr[i] = rand.nextInt(max+1);
        }
        return arr;
    }






    public static int sum(int num1,int num2){
        int num = num1 + num2;
        return  num;
    }
}
